/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-29
 * Time: 18:33
 */
class NameException extends Exception {
    public NameException() {
        super();
    }

    public NameException(String s) {
        super(s);
    }
}
public class Test {
    public static void func1() throws NameException{
       int a = 1;
     /* try {
          if(a != 1) {
              throw new NameException();
          }
      }catch (NameException e) {

      }*/
        if(a != 1) {
            throw new NameException();
        }
    }

    public static void main(String[] args) {
       // func1();
        try {
            func1();
        }catch (NameException e) {

        }
    }
    public static void test2() {
        int[] arr = {1,2,3,4,5,6};
        try {
            System.out.println(arr[10]);
        }catch (ArithmeticException e) {
            e.printStackTrace();
        }catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        }catch (NullPointerException e) {
            e.printStackTrace();
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            System.out.println("finally一定被执行");
        }
    }
    public static void main1(String[] args) {
        test2();
        System.out.println("after");
    }
}
